<?php
/**
*
*	注册问题管理 @zairwolf
*
*/
if(!defined('IN_ACP')) exit('Access Denied');

//问题更新
if($action == 'update') {
	$regq=_post('regq');
	if(!$regq) b('输入内容错误');

	foreach($regq as $key=>$val){
		$val['title']=trim($val['title']);
		if(empty($val['title'])){//刪除此條記錄
			$cols=array('active' => 0);
		}else{
			$cols=array('title'=>$val['title'], 'key1'=>$val['key1'], 'key2'=>$val['key2'], 'key3'=>$val['key3'], 'key4'=>$val['key4'], 'solution'=>$val['solution'], );
		}
		if($key>0) db_q("update rd8_regq set ".sqlcol($cols)." where id='$key'");
		elseif(!empty($val['title'])){//插入新的
			$cols['active']=1;
			db_i("insert into rd8_regq set ".sqlcol($cols));
		}
		
	}
}


//默认显示
if(!$action){
	$list=db_rows("select * from rd8_regq where active=1 order by id");
	$list[]=array('id'=>'0','title'=>'','key1'=>'','key2'=>'','key3'=>'','key4'=>'','solution'=>'1',);//添加內容用

	$tpl = new T($ptype.'_'.$pfile);
	$tpl->assign('list', html_show($list, false));
	$tpl->output();
}
